return false;
}
- if (!conn->write && (perm & XS_PERM_WRITE)) {
+ if (!conn->can_write && (perm & XS_PERM_WRITE)) {
errno = EROFS;
return false;
}
return do_set_perms(conn, in);
case XS_SHUTDOWN:
+ /* FIXME: Implement gentle shutdown too. */
+ /* Only tools can do this. */
+ if (conn->id != 0)
+ return send_error(conn, EACCES);
+ if (!conn->can_write)
+ return send_error(conn, EROFS);
send_ack(conn, XS_SHUTDOWN);
/* Everything hangs off auto-free context, freed at exit. */
exit(0);
new->transaction = NULL;
new->write = write;
new->read = read;
+ new->can_write = true;
talloc_set_fail_handler(out_of_mem, &talloc_fail);
if (setjmp(talloc_fail)) {
if (fd < 0)
return;
- conn = new_connection(canwrite ? writefd : NULL, readfd);
- if (conn)
+ conn = new_connection(writefd, readfd);
+ if (conn) {
conn->fd = fd;
- else
+ conn->can_write = canwrite;
+ } else
close(fd);
}
/* Are we blocked waiting for a transaction to end? Contains node. */
char *blocked;
+ /* Is this a read-only connection? */
+ bool can_write;
+
/* Our current event. If all used, we're waiting for ack. */
struct watch_event *event;
if (get_strings(in, vec, ARRAY_SIZE(vec)) < ARRAY_SIZE(vec))
return send_error(conn, EINVAL);
+ if (!conn->can_write)
+ return send_error(conn, EROFS);
+
/* Hang domain off "in" until we're finished. */
domain = talloc(in, struct domain);
domain->domid = atoi(vec[0]);
" watch <path> <prio>\n"
" waitwatch\n"
" ackwatch\n"
- " unwatch <path>\n"
+ " unwatch <path> <token>\n"
" close\n"
" start <node>\n"
" abort\n"
- " introduce <domid> <mfn> <eventchn>\n"
+ " introduce <domid> <mfn> <eventchn> <path>\n"
" commit\n"
" sleep <seconds>\n"
" dump\n");